package com.example.demo;

import java.lang.annotation.Annotation;
@MyAnnotation(name = "MyUser")
public class User {
    private String name;
    private int age;
}
public class Test04 {
    public static void main(String[] args)throws ClassNotFoundException{

        Class aClass = Class.forName("com.ndky.User");
        Annotation declareAnnotation = aClass.getAnnotation(MyAnnotation.class);

        if (declareAnnotation instanceof MyAnnotation){
            MyAnnotation myAnnotation =(MyAnnotation) declareAnnotation;
            System.out.println(myAnnotation.name());
        }
        if(declareAnnotation instanceof RestController){
            System.out.println("declaredAnnotation is a RestController annotation");

        }
        else{
            System.out.println("declaredAnnotation is a RestController annotation");
        }
    }

}
